package com.medicine.hbp.adapter;

import java.util.ArrayList;
import java.util.List;

import com.medicine.hbp.mob.AdlnfoVo;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;

public class ImageFragmentAdapter extends FragmentStatePagerAdapter {

	public ImageFragmentAdapter(FragmentManager fm) {
		super(fm);
	}

	protected List<AdlnfoVo> adInfo = new ArrayList<AdlnfoVo>();

    @Override
    public Fragment getItem(int position) {
        return ImageFragment.newInstance(adInfo.get(position % adInfo.size()));
    }

    @Override
    public int getCount() {
        return 100;
    }

    @Override
    public CharSequence getPageTitle(int position) {
      return adInfo.get(position % adInfo.size()).adImg;
    }

    public void setData(List<AdlnfoVo> mUrls) {
    	if(adInfo!=null){
    		adInfo = mUrls;
    	    notifyDataSetChanged();
    	}
    }
}